﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace omaura_oled
{
    public class AppDataValidator
    {
        #region "Parameters"
        //--
        public static string PathToAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\omaura\\omaura oled\\";
        public static string PathToProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\omaura\\omaura oled\\";
        //--
        public static bool AppDataFolderCorrect = false;
        //--
        #endregion "Parameters"

        #region "Methods"
        //--
        public static void CheckAppDataFolders()
        {
            AppDataFolderCorrect = false;

            if (File.Exists(PathToAppData + "Config.ini")
                && File.Exists(PathToAppData + "Script.txt")
                && File.Exists(PathToAppData + "Weather.txt")
                && File.Exists(PathToAppData + "Log-oled.txt")
                && File.Exists(PathToAppData + "Install.txt")
                )
                AppDataFolderCorrect = true;
        }
        //--
        public static void CreateAppDataFolders()
        {
            if (!AppDataFolderCorrect)
            {
                //-- create folders
                if (!Directory.Exists(PathToAppData))
                    Directory.CreateDirectory(PathToAppData);

                //-- create files
                //--- copy from ProgramData folder
                if (!File.Exists(PathToAppData + "Config.ini"))
                    File.Copy(PathToProgramData + "Config.ini", PathToAppData + "Config.ini");
                if (!File.Exists(PathToAppData + "Script.txt"))
                    File.Copy(PathToProgramData + "Script.txt", PathToAppData + "Script.txt");
                if (!File.Exists(PathToAppData + "Weather.txt"))
                    File.Copy(PathToProgramData + "Weather.txt", PathToAppData + "Weather.txt");
//                if (!File.Exists(PathToAppData + "Install.txt"))
//                    File.Copy(PathToProgramData + "Install.txt", PathToAppData + "Install.txt");

                //--- create empty Log-oled,txt file
                if (!File.Exists(PathToAppData + "Log-oled.txt"))
                    File.Create(PathToAppData + "Log-oled.txt");
            }
        }
        //--
        #endregion "Methods"
    }
}
